package org.hdl.anima.transport.support;

import org.hdl.anima.AppConf;
import org.hdl.anima.transport.Channel;
import org.hdl.anima.transport.ChannelHandler;
import org.hdl.anima.transport.RemoteException;

/**
 * 
 * @author qiuhd
 * @since  2014-8-1
 * @version V1.0.0
 */
public abstract class AbstractChannel extends AbstractEndpoint implements Channel{

	public AbstractChannel(AppConf conf, ChannelHandler handler) {
		super(conf, handler);
	}
	
	@Override
	public void send(Object message) throws RemoteException {
		if (isClosed()) {
			throw new RemoteException("Failed to send message " + message
					+ " to " + getRemoteAddress()
					+ "Cause: Channel is already colsed." + "channel : "
					+ getLocalAddress() + " -> " + getRemoteAddress());
		}
	}

	@Override
	public String toString() {
		return getLocalAddress().toString() ;
	}
}

